-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Gmail client and update email functions #944
Conversation
subject = ( | ||
f"{current_app.config.get('OO_MAIL_SUBJECT_PREFIX')} Reset Your Password" | ||
) | ||
body = render_template("auth/email/reset_password.html", user=user, token=token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**NOTE:** If you are running on dev and do not currently have a `service_account_key.json` file, create one and leave it empty. The email client will then default to an empty object and simulate emails in the logs. | ||
|
||
For the application to work properly, you will need a [Google Cloud Platform service account](https://cloud.google.com/iam/docs/service-account-overview) that is attached to a GSuite email address. Here are some general tips for working with service accounts: [Link](https://support.google.com/a/answer/7378726?hl=en). | ||
We would suggest that you do not use a personal email address, but instead one that is used strictly for sending out OpenOversight emails. | ||
|
||
You will need to do these two things for the service account to work as a Gmail bot: | ||
1. Enable domain-wide delegation for the service account: [Link](https://support.google.com/a/answer/162106?hl=en) | ||
2. Enable the `https://www.googleapis.com/auth/gmail.send` scope in the Gmail API for your service account: [Link](https://developers.google.com/gmail/api/auth/scopes#scopes) | ||
3. Save the service account key file in OpenOversight's base folder as `service_account_key.json`. The file is in the `.gitignore` file GitHub will not allow you to save it, provided you've named it correctly. | ||
4. For production, save the email address associated with your service account to a variable named `OO_SERVICE_EMAIL` in a `.env` file in the base directory of this repository. For development and testing, update the `OO_SERVICE_EMAIL` variable in the `docker-compose.yml` file. | ||
|
||
Example `.env` variable: | ||
```bash | ||
OO_SERVICE_EMAIL="[email protected]" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be all of the info needed, @abandoned-prototype.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing all my suggestions. This looks great now!
I realized that I don't seem to have access to the required service_account_key.json
file, so I will merge this tomorrow after setting that file up correctly on staging
lucyparsons#927 Add the ability to send emails from a Google Workspace account using a GCP service account and update the feature's respective documentation. - Need `service_account_key.json` file that is stored in LPL document storage. --------- Co-authored-by: abandoned-prototype <[email protected]>
lucyparsons#927 Add the ability to send emails from a Google Workspace account using a GCP service account and update the feature's respective documentation. - Need `service_account_key.json` file that is stored in LPL document storage. --------- Co-authored-by: abandoned-prototype <[email protected]>
lucyparsons#927 Add the ability to send emails from a Google Workspace account using a GCP service account and update the feature's respective documentation. - Need `service_account_key.json` file that is stored in LPL document storage. --------- Co-authored-by: abandoned-prototype <[email protected]>
lucyparsons#927 Add the ability to send emails from a Google Workspace account using a GCP service account and update the feature's respective documentation. - Need `service_account_key.json` file that is stored in LPL document storage. --------- Co-authored-by: abandoned-prototype <[email protected]>
Fixes issue
#927
Description of Changes
Add the ability to send emails from a Google Workspace account using a GCP service account and update the feature's respective documentation.
Notes for Deployment
service_account_key.json
file that is stored in LPL document storage.Email Screenshots
Administrator Approval Email:
Confirm Account Email:
Change Email Address Email:
Confirmed User Email:
Reset Password Email:
Tests and linting
develop
branch.pytest
passes on my local development environment.pre-commit
passes on my local development environment.